<?php
/**
 * Created by PhpStorm.
 * User: xiaomeng
 * Date: 17-9-14
 * Time: 下午5:41
 */
$a = [25,2,5,2,3,2,8,3,2,5,2,3,2,5,2,3,12,3,8,2,5,3,2,3,12,2,5,2,8,2,3,2];

$_a=[2=>0,3=>0,5=>0,8=>0,12=>0,25=>0];

foreach ($a as $v)
{
    $_a[$v] +=1;
}

$_aa =[];
foreach ($_a as $k=>$v)
{
    $_aa[$k] = $v/32 *100;
}

$b = [];

$ci = 200;

//own
//for($i=0;$i<$ci;$i++)
//{
////    usleep(20);
//    $c = rand(0,31);
//    array_unshift($b,$a[$c]);
//}

//jiqi
for($i=0;$i<$ci;$i++)
{
//    usleep(20);
    $c = (int)trim(file_get_contents("https://www.random.org/integers/?num=1&min=0&max=31&col=1&base=10&format=plain&rnd=new"));
    array_unshift($b,$a[$c]);
}

$d=[2=>0,3=>0,5=>0,8=>0,12=>0,25=>0];

foreach ($b as $v)
{
    $d[$v] +=1;
}

$e = [];
foreach ($d as $k=>$v)
{
    $e[$k] = $v/$ci *100;
}
var_dump($_aa);
var_dump($e);